<?php
namespace app\api\service;
use auth\Auths;
use base\service\SmsApi;
use app\admin\model\SystemUser as UserModel;

class User extends \app\resources\service\BaseService
{

   	/*
	 * 初始
	 */
    public function __construct(){
    	$this->model = new UserModel();
    }
	
    /**
     * 账密登录
    */
    public function pwdLogin($usercode,$pwd){
		$map['user_code'] = $usercode;
		$map['user_pwd'] = md5('wei'.md5($pwd));
		$map['user_type'] = 1;
		$map['is_enable'] = 1;
		$userInfo = $this->model->where($map)->find();
		if( $userInfo == null ){
			throw new \think\Exception('账号和密码不符');
		}
		return Auths::instance('api')->login($userInfo);
    }
	
}